package com.sg.service.biz.calc.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.calc.req.ObtainStandardDataColumnToMultiRowComReqDto;
import com.sg.dto.biz.calc.req.ObtainStandardDataColumnToMultiRowReqDto;
import com.sg.dto.biz.calc.res.ObtainStandardDataColumnToMultiRowComRespDto;
import com.sg.dto.biz.calc.res.ObtainStandardDataColumnToMultiRowRespDto;
import com.sg.service.biz.calc.nb.NbColumnToRow;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class ColumnToRowServiceImpl
        implements com.wicket.okrcalc.biz.service.ColumnToRowService {

    @Resource
    private RedisUtil redisUtil;
    //@Resource
    //private MCustomFieldsService mCustomFieldsService;
    @Resource
    private NbColumnToRow nbColumnToRow;

    /**
     * D4获取标准数据列转多行(公共)[8023]
     * gen by moon at 11/26/2023, 11:45:35 AM
     */
    @Trace(operationName = "D4获取标准数据列转多行(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ObtainStandardDataColumnToMultiRowComRespDto obtainStandardDataColumnToMultiRowCom(ObtainStandardDataColumnToMultiRowComReqDto reqDto) {


        ObtainStandardDataColumnToMultiRowRespDto multiColumnToMultiRowRes_1 = null;
//步骤0: M4-获取标准数据列转多行（特殊方法） - obtainStandardDataColumnToMultiRow
        //ModelCode: multiColumnToMultiRow
        ObtainStandardDataColumnToMultiRowRespDto multiColumnToMultiRowRes = null;
        ObtainStandardDataColumnToMultiRowReqDto multiColumnToMultiRowReq = new ObtainStandardDataColumnToMultiRowReqDto();
        if (reqDto != null && reqDto.getStandardDataList() != null && !CollectionUtil.isEmpty(reqDto.getStandardDataList())) {
            multiColumnToMultiRowReq.setStandardDataList(reqDto.getStandardDataList().stream().map(item -> BeanUtil.toBean(item, StandardDataDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:1353397_1
        }

        /*M4-获取标准数据列转多行（特殊方法）[2469]   */

        multiColumnToMultiRowRes = nbColumnToRow.obtainStandardDataColumnToMultiRow(multiColumnToMultiRowReq);


        multiColumnToMultiRowRes_1 = multiColumnToMultiRowRes;

        ObtainStandardDataColumnToMultiRowComRespDto retData = new ObtainStandardDataColumnToMultiRowComRespDto();
        retData.setStandardDataList(//objList-to-objLists
                multiColumnToMultiRowRes_1.getStandardDataList().stream().map(item -> {
                    StandardDataDto elm = new StandardDataDto();
                    if (item != null) {
                        elm.setEntityId(item.getEntityId());//SimpleFieldAssign//sourceId:275107_2
                        elm.setFromContentEntityId(item.getFromContentEntityId());//SimpleFieldAssign//sourceId:274985_2
                        elm.setActualValue(item.getActualValue());//SimpleFieldAssign//sourceId:275042_2
                        elm.setWorkCycleUpdateSlice(item.getWorkCycleUpdateSlice());//SimpleFieldAssign//sourceId:274986_2
                        elm.setCountActualValue(item.getCountActualValue());//SimpleFieldAssign//sourceId:275043_2
                        elm.setActualValue(item.getActualValue());//SimpleFieldAssign//sourceId:274987_2
                        elm.setChangeFromLastTarget(item.getChangeFromLastTarget());//SimpleFieldAssign//sourceId:275044_2
                        elm.setActualValueUnit(item.getActualValueUnit());//SimpleFieldAssign//sourceId:274988_2
                        elm.setCountChangeFromLastTarget(item.getCountChangeFromLastTarget());//SimpleFieldAssign//sourceId:275045_2
                        elm.setFromLastTargetLiftRatio(item.getFromLastTargetLiftRatio());//SimpleFieldAssign//sourceId:275046_2
                        elm.setProgressValue(item.getProgressValue());//SimpleFieldAssign//sourceId:274989_2
                        elm.setProgressValueUnit(item.getProgressValueUnit());//SimpleFieldAssign//sourceId:274990_2
                        elm.setCountFromLastTargetLiftRatio(item.getCountFromLastTargetLiftRatio());//SimpleFieldAssign//sourceId:275047_2
                        elm.setProgressFromLastRatio(item.getProgressFromLastRatio());//SimpleFieldAssign//sourceId:274991_2
                        elm.setProgressValue(item.getProgressValue());//SimpleFieldAssign//sourceId:275048_2
                        elm.setReach(item.getReach());//SimpleFieldAssign//sourceId:274992_2
                        elm.setCountProgressValue(item.getCountProgressValue());//SimpleFieldAssign//sourceId:275049_2
                        elm.setFromLastProgressValue(item.getFromLastProgressValue());//SimpleFieldAssign//sourceId:275050_2
                        elm.setActualFromLastTimeRatio(item.getActualFromLastTimeRatio());//SimpleFieldAssign//sourceId:274993_2
                        elm.setRealTimeScore(item.getRealTimeScore());//SimpleFieldAssign//sourceId:274994_2
                        elm.setCountFromLastProgressValue(item.getCountFromLastProgressValue());//SimpleFieldAssign//sourceId:275051_2
                        elm.setProgressFromLastRatioUnit(item.getProgressFromLastRatioUnit());//SimpleFieldAssign//sourceId:274995_2
                        elm.setProgressFromLastRatio(item.getProgressFromLastRatio());//SimpleFieldAssign//sourceId:275052_2
                        elm.setReachUnit(item.getReachUnit());//SimpleFieldAssign//sourceId:274996_2
                        elm.setCountProgressFromLastRatio(item.getCountProgressFromLastRatio());//SimpleFieldAssign//sourceId:275053_2
                        elm.setReach(item.getReach());//SimpleFieldAssign//sourceId:275054_2
                        elm.setActualFromLastTimeRatioUnit(item.getActualFromLastTimeRatioUnit());//SimpleFieldAssign//sourceId:274997_2
                        elm.setRealTimeScoreUnit(item.getRealTimeScoreUnit());//SimpleFieldAssign//sourceId:274998_2
                        elm.setEvaCalcType(item.getEvaCalcType());//SimpleFieldAssign//sourceId:275055_2
                        elm.setFromLastReach(item.getFromLastReach());//SimpleFieldAssign//sourceId:275056_2
                        elm.setPeriodId(item.getPeriodId());//SimpleFieldAssign//sourceId:274999_2
                        elm.setCycleStartTime(item.getCycleStartTime());//SimpleFieldAssign//sourceId:275000_2
                        elm.setBudget(item.getBudget());//SimpleFieldAssign//sourceId:275057_2
                        elm.setActualFromLastTimeRatio(item.getActualFromLastTimeRatio());//SimpleFieldAssign//sourceId:275058_2
                        elm.setCycleEndTime(item.getCycleEndTime());//SimpleFieldAssign//sourceId:275001_2
                        elm.setFundsReceived(item.getFundsReceived());//SimpleFieldAssign//sourceId:275059_2
                        elm.setCycleTypeCode(item.getCycleTypeCode());//SimpleFieldAssign//sourceId:275002_2
                        elm.setFundsExpend(item.getFundsExpend());//SimpleFieldAssign//sourceId:275060_2
                        elm.setCycleTypeInstanceCode(item.getCycleTypeInstanceCode());//SimpleFieldAssign//sourceId:275003_2
                        elm.setPersonLiableObjId(item.getPersonLiableObjId());//SimpleFieldAssign//sourceId:275004_2
                        elm.setBudgetAmount(item.getBudgetAmount());//SimpleFieldAssign//sourceId:275061_2
                        elm.setBizRoleObjId(item.getBizRoleObjId());//SimpleFieldAssign//sourceId:275005_2
                        elm.setFundsReceivedBalance(item.getFundsReceivedBalance());//SimpleFieldAssign//sourceId:275062_2
                        elm.setRealTimeScore(item.getRealTimeScore());//SimpleFieldAssign//sourceId:275063_2
                        elm.setBizRoleObjCode(item.getBizRoleObjCode());//SimpleFieldAssign//sourceId:275006_2
                        elm.setSubjectiveMark(item.getSubjectiveMark());//SimpleFieldAssign//sourceId:275064_2
                        elm.setPersonLiableTypeCode(item.getPersonLiableTypeCode());//SimpleFieldAssign//sourceId:275007_2
                        elm.setBizRoleObjName(item.getBizRoleObjName());//SimpleFieldAssign//sourceId:275008_2
                        elm.setSubjectiveScore(item.getSubjectiveScore());//SimpleFieldAssign//sourceId:275065_2
                        elm.setChangeFromLastTarget(item.getChangeFromLastTarget());//SimpleFieldAssign//sourceId:275009_2
                        elm.setActualValueUnit(item.getActualValueUnit());//SimpleFieldAssign//sourceId:275066_2
                        elm.setCountActualValueUnit(item.getCountActualValueUnit());//SimpleFieldAssign//sourceId:275067_2
                        elm.setChangeFromLastTargetUnit(item.getChangeFromLastTargetUnit());//SimpleFieldAssign//sourceId:275010_2
                        elm.setChangeFromLastTargetUnit(item.getChangeFromLastTargetUnit());//SimpleFieldAssign//sourceId:275068_2
                        elm.setReportScore(item.getReportScore());//SimpleFieldAssign//sourceId:275011_2
                        elm.setReportScoreUnit(item.getReportScoreUnit());//SimpleFieldAssign//sourceId:275012_2
                        elm.setCountChangeFromLastTargetUnit(item.getCountChangeFromLastTargetUnit());//SimpleFieldAssign//sourceId:275069_2
                        elm.setActualScore(item.getActualScore());//SimpleFieldAssign//sourceId:275013_2
                        elm.setFromLastTargetLiftRatioUnit(item.getFromLastTargetLiftRatioUnit());//SimpleFieldAssign//sourceId:275070_2
                        elm.setCountFromLastTargetLiftRatioUnit(item.getCountFromLastTargetLiftRatioUnit());//SimpleFieldAssign//sourceId:275071_2
                        elm.setActualScoreUnit(item.getActualScoreUnit());//SimpleFieldAssign//sourceId:275014_2
                        elm.setProgressValueUnit(item.getProgressValueUnit());//SimpleFieldAssign//sourceId:275072_2
                        elm.setFromLastTargetLiftRatio(item.getFromLastTargetLiftRatio());//SimpleFieldAssign//sourceId:275015_2
                        elm.setFromLastProgressValue(item.getFromLastProgressValue());//SimpleFieldAssign//sourceId:275016_2
                        elm.setCountProgressValueUnit(item.getCountProgressValueUnit());//SimpleFieldAssign//sourceId:275073_2
                        elm.setFromLastReach(item.getFromLastReach());//SimpleFieldAssign//sourceId:275017_2
                        elm.setFromLastProgressValueUnit(item.getFromLastProgressValueUnit());//SimpleFieldAssign//sourceId:275074_2
                        elm.setCountFromLastProgressValueUnit(item.getCountFromLastProgressValueUnit());//SimpleFieldAssign//sourceId:275075_2
                        elm.setFromLastTargetLiftRatioUnit(item.getFromLastTargetLiftRatioUnit());//SimpleFieldAssign//sourceId:275018_2
                        elm.setProgressFromLastRatioUnit(item.getProgressFromLastRatioUnit());//SimpleFieldAssign//sourceId:275076_2
                        elm.setFromLastProgressValueUnit(item.getFromLastProgressValueUnit());//SimpleFieldAssign//sourceId:275019_2
                        elm.setFromLastReachUnit(item.getFromLastReachUnit());//SimpleFieldAssign//sourceId:275020_2
                        elm.setCountProgressFromLastRatioUnit(item.getCountProgressFromLastRatioUnit());//SimpleFieldAssign//sourceId:275077_2
                        elm.setActualScoreValue(item.getActualScoreValue());//SimpleFieldAssign//sourceId:275021_2
                        elm.setReachUnit(item.getReachUnit());//SimpleFieldAssign//sourceId:275078_2
                        elm.setActualFromLastTimeRatioUnit(item.getActualFromLastTimeRatioUnit());//SimpleFieldAssign//sourceId:275079_2
                        elm.setReportScoreValue(item.getReportScoreValue());//SimpleFieldAssign//sourceId:275022_2
                        elm.setFundsReceivedUnit(item.getFundsReceivedUnit());//SimpleFieldAssign//sourceId:275080_2
                        elm.setBudget(item.getBudget());//SimpleFieldAssign//sourceId:275023_2
                        elm.setBudgetUnit(item.getBudgetUnit());//SimpleFieldAssign//sourceId:275024_2
                        elm.setFundsExpendUnit(item.getFundsExpendUnit());//SimpleFieldAssign//sourceId:275081_2
                        elm.setBudgetAmount(item.getBudgetAmount());//SimpleFieldAssign//sourceId:275025_2
                        elm.setBudgetAmountUnit(item.getBudgetAmountUnit());//SimpleFieldAssign//sourceId:275082_2
                        elm.setFundsReceivedBalanceUnit(item.getFundsReceivedBalanceUnit());//SimpleFieldAssign//sourceId:275083_2
                        elm.setBudgetAmountUnit(item.getBudgetAmountUnit());//SimpleFieldAssign//sourceId:275026_2
                        elm.setRealTimeScoreUnit(item.getRealTimeScoreUnit());//SimpleFieldAssign//sourceId:275084_2
                        elm.setFundsReceived(item.getFundsReceived());//SimpleFieldAssign//sourceId:275027_2
                        elm.setFundsReceivedFromLast(item.getFundsReceivedFromLast());//SimpleFieldAssign//sourceId:275028_2
                        elm.setReportScore(item.getReportScore());//SimpleFieldAssign//sourceId:275085_2
                        elm.setCumulativeFundsReceived(item.getCumulativeFundsReceived());//SimpleFieldAssign//sourceId:275029_2
                        elm.setReportScoreUnit(item.getReportScoreUnit());//SimpleFieldAssign//sourceId:275086_2
                        elm.setActualScore(item.getActualScore());//SimpleFieldAssign//sourceId:275087_2
                        elm.setFundsReceivedBalance(item.getFundsReceivedBalance());//SimpleFieldAssign//sourceId:275030_2
                        elm.setActualScoreUnit(item.getActualScoreUnit());//SimpleFieldAssign//sourceId:275088_2
                        elm.setFundsReceivedFromLastRatio(item.getFundsReceivedFromLastRatio());//SimpleFieldAssign//sourceId:275031_2
                        elm.setCountFromLastReachRatioUnit(item.getCountFromLastReachRatioUnit());//SimpleFieldAssign//sourceId:275032_2
                        elm.setFundsReceivedUnit(item.getFundsReceivedUnit());//SimpleFieldAssign//sourceId:275033_2
                        elm.setFundsReceivedFromLastRatioUnit(item.getFundsReceivedFromLastRatioUnit());//SimpleFieldAssign//sourceId:275034_2
                        elm.setCumulativeFundsReceivedUnit(item.getCumulativeFundsReceivedUnit());//SimpleFieldAssign//sourceId:275035_2
                        elm.setFundsReceivedBalanceUnit(item.getFundsReceivedBalanceUnit());//SimpleFieldAssign//sourceId:275036_2
                        elm.setSourceBudgetFundsProp(item.getSourceBudgetFundsProp());//SimpleFieldAssign//sourceId:275037_2
                        elm.setSourceBudgetFundsPropUnit(item.getSourceBudgetFundsPropUnit());//SimpleFieldAssign//sourceId:275038_2
                        elm.setTargetCycleBudgetFundsProp(item.getTargetCycleBudgetFundsProp());//SimpleFieldAssign//sourceId:275039_2
                        elm.setTargetCycleBudgetFundsPropUnit(item.getTargetCycleBudgetFundsPropUnit());//SimpleFieldAssign//sourceId:275040_2
                    }
                    return elm;
                }).collect(Collectors.toList()));//objList-to-objLists//sourceId:1353448_1


        return retData;
    }
    //
}
